from PIL import Image

"""
用pillow裁剪出来的图片会小一点
"""

# 裁切图片
# img_name = '1112101839-004'
# img_name = '1112101839-005'
# img_name = '1112101839-007'
img_suffix = '.jpg'
# img = Image.open("../pic/" + img_name + img_suffix)
# print(img.size)
# cropped = img.crop((0, 10, 650, 90))  # (left, upper, right, lower)
# cropped.save("../pic/cut/" + img_name + "_cut" + img_suffix)


# 将图片转为黑底白字
img_name = 'car'
# img_path = "../car/cut/" + img_name + "_cut" + img_suffix
img_path = "../pic/pillow/car_a_200.jpg"
image_file = Image.open(img_path)  # open colour image
image_file = image_file.convert('1')  # convert image to black and white
save_path = "../pic/cut/" + img_name + "_cut_con" + img_suffix
image_file.save(save_path)


